package com.aistar.controller;

import com.aistar.pojo.Member;
import com.aistar.service.MemberService;
import com.aistar.service.reply.ReplyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.*;


/**
 * @author shkstart
 * @date 2019/10/6 - 10:49
 */
@Controller
public class ReplyController {
    @Autowired
    private ReplyService replyService;
    @Autowired
    private MemberService memberService;

    //    请求发出用户id
    @RequestMapping("reply/toaccount/{userId}")
    public ModelAndView reply(@PathVariable("userId") int userId, HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView();
        Object ss = request.getSession().getAttribute("userId");//获得session里的用户id
        int aa = Integer.parseInt(String.valueOf(ss));
        Member member = memberService.getbyId(aa);

        modelAndView.addObject("memberall",member);
        modelAndView.setViewName("Reply/reply");
        List<Map> list = replyService.reply(userId);
        modelAndView.addObject("list",list);
//        System.out.println("pageInfo.getList():"+pageInfo);
        return modelAndView ;
    }

}
